Use case: Retrieve device information ¶
This use case shows how to retrieve device identifiers (revision/device IDs, unique ID) and the HAL version.
Sequence diagram ¶
Code snippet ¶
|
HAL1 |
HAL2 |
|---|---|
int main(void)
{
HAL_Init();
/*
...
*/
uint32_t tmp0;
uint32_t tmp1;
uint32_t tmp2;
tmp0 = HAL_GetUIDw0();
tmp1 = HAL_GetUIDw1();
tmp2 = HAL_GetUIDw2();
printf("Device unique ID: %d-%d-%d", tmp0, tmp1, tmp2);
uint32_t version = HAL_GetHalVersion();
printf("HAL Version: %d", version);
}
|
int main(void)
{
HAL_Init();
/*
...
*/
hal_device_uid_t device_uid;
HAL_GetDeviceUniqueID(&device_uid);
printf("Device unique ID: %d-%d-%d", device_uid.uid_0, device_uid.uid_1, device_uid.uid_2);
uint32_t version = HAL_GetVersion();
printf("HAL Version: %d", version);
}
|
Key changes ¶
In HAL2, revision and device ID access is provided by the dedicated DBGMCU driver (for example
HAL_DBGMCU_GetRevisionID()andHAL_DBGMCU_GetDeviceID()).In HAL2, the unique device ID getters are consolidated into
HAL_GetDeviceUniqueID(hal_device_uid_t *p_uid).In HAL2,
HAL_GetVersion()replacesHAL_GetHalVersion().

